package com.wechat.back.utils.ACF;

import java.util.HashMap;
import java.util.Map;

class ACTreeNode {
    private Map<Character, ACTreeNode> children = new HashMap<>();
    private ACTreeNode failover = null;
    private int depth;
    private boolean isLeaf = false;

    public void addChildrenIfAbsent(char c) {
        children.putIfAbsent(c, new ACTreeNode());
    }

    public Map<Character, ACTreeNode> getChildren() {
        return children;
    }

    public ACTreeNode childOf(char c) {
        return children.get(c);
    }

    public boolean hasChild(char c) {
        return children.containsKey(c);
    }

    public void setFailover(ACTreeNode failover) {
        this.failover = failover;
    }

    public ACTreeNode getFailover() {
        return failover;
    }

    public void setDepth(int depth) {
        this.depth = depth;
    }

    public int getDepth() {
        return depth;
    }

    public void setLeaf(boolean leaf) {
        isLeaf = leaf;
    }

    public boolean isLeaf() {
        return isLeaf;
    }

}    